package com.dev.module_ui_composable.lce

import androidx.compose.runtime.Composable

/**
 * 根据 State 的页面封装
 * @param uiState 数据状态
 * @param onRetryClick 重试请求
 * @param content 显示数据加载成功的 @Composable
 */
@Composable
fun <T> LcePage(
    uiState: AppUiState<T>,
    onRetryClick: () -> Unit = {},
    content: @Composable (result: T) -> Unit
) {
    when (uiState) {
        AppUiLoading -> {
            LoadingContent()
        }
        is AppUiError -> {
            ErrorContent(onErrorClick = onRetryClick)
        }
        is AppNoContent -> {
            NoContent()
        }
        is AppUiSuccess -> {
            content(uiState.data)
        }
    }
}